<?php

require_once 'bootstrap.php';

$sport_id = isset($_GET['id'])?$_GET['id']:0;;
$zipcode = isset($_GET['zipcode'])?$_GET['zipcode']:'';

$sports = $my_db->select_pairs('SELECT * FROM sports');
$leagues = $my_db->select('SELECT * FROM leagues WHERE zipcode = ? AND sport = ?', array($zipcode,$sport_id));
$ads = $my_db->select('SELECT * FROM ads WHERE zipcode = ?', array($zipcode));

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $front_title; ?></title>
<?php include("__head_tag.php");?>
</head>
<body>
<div id="wrap">
<?php include("__header.php"); ?>

<?php include("__nav.php"); ?>

<div id="content">
  <p>&nbsp;</p>
<h2>Baseball Results </h2>
<p>
	<div align="center">Youth <?=$sports[$sport_id]?> available in <?=$zipcode?></div>
    <br />
    <table width="100%" border="3" cellspacing="1" cellpadding="1">
	    <?php
	        foreach ($leagues as $count => $league):
		        echo '<tr>';
				echo '<td width="70%">';
		        echo '<table cellspacing="3" cellpadding="3">';
		        echo '<tr><td with="60%"  >';
		        echo '<strong>'.$league['firstName'] . ' '.$league['lastName'].'</strong>';
		        echo '<br/>';
		        echo $league['url'];
		        echo '</td><td>';
			    echo 'Registration Start: '. $league['registrationStart'];
		        echo '<br/>';
		         echo 'Registration End: '. $league['registrationEnd'];
		        echo '</td></tr><tr><td>';
		        echo $league['address'];
		         echo '<br/>';
		        echo $league['city'] .','. $league['state'].'. '.$league['zipcode'];
		         echo '<br/>';
		        echo $league['phone'];
		        echo '</td><td>';
		         echo 'Season Start: '. $league['seasonStart'];
		        echo '<br/>';
		         echo 'Season End: '. $league['seasonEnd'];
		        echo '</td>';
		        echo '</tr></table>';
		        echo '</td>';
		        echo '<td>';
		        echo isset($ads[$count]['descr'])?$ads[$count]['descr']:'ads here';
		        echo '</td>';
		        echo '</tr>';
	    ?>
		<?php endforeach ?>
    </table>
    </p>
</div>
<?php include("__footer.php"); ?>
</div>
</body>
</html>